# mysql crud 省略
import pymysql

try:
    conn = pymysql.connect(
        host="127.0.0.1",
        user="root",
        password="root",
        database="route_data",
        port=3306,
        charset="utf8"
    )
    cursor = conn.cursor()
except Exception as e:
    print(e)
#     无报错执行sql
else:
    # select
    sql = "select * from user limit %s"
    cursor.execute(query=sql, args=[2])
    result = cursor.fetchall()
    print(result)
    # insert
    insert_sql = "insert into p_user values(%s,%s,%s)"
    cursor.execute(query=insert_sql, args=[None, '小张', '123456789'])
    conn.commit()

    cursor.close()
    conn.close()
